/**
 * 金额千分格式化处理
 * @param {Object} num 待处理的数值
 */
export function thousandthFormat(num){
  let str = num + ''
  let prefix = '';
  // 添加负数情况
  if( str.charAt(0) == '-'){
	  prefix = '-';
	  str = str.slice(1);
  } 
  const parts = str.split('.')
  const whole = parts[0]
  const decimal = parts.length > 1 ? '.' + parts[1] : ''
  const len = whole.length
  if (len <= 3) {
    return str
  }
  const remainder = len % 3
  let result = remainder > 0 ? whole.slice(0, remainder) : ''
  for (let i = remainder; i < len; i += 3) {
    if (result !== '') {
      result += ','
    }
    result += whole.slice(i, i + 3)
  }
  return prefix + result + decimal
}

/**
 * 点击跳转事件
 * @param {Object} url 跳转地址
 */
export function redirectTo(url){
	uni.navigateTo({
		url: url
	});
}
